package thread;

import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class ThreadSleep implements Runnable {
	Random rand = new Random();
	int sleepTime = rand.nextInt(10000);
	
	public void run(){
		try{
			Thread.currentThread();
			System.out.println("I will sleep " + sleepTime + " milliseconds " + Thread.currentThread().getName());
			Thread.sleep(sleepTime);
		}catch(InterruptedException e){
			System.out.println(e);
		}
	}
	
	public static void main(String[] args){
		//ExecutorService exec = Executors.newSingleThreadExecutor();
		for(int i =0; i < 5; i++){
			Thread t = new Thread(new ThreadSleep());
			t.setDaemon(true);
			//new Thread(new ThreadSleep()).start();
			t.start();
			//exec.execute(new ThreadSleep());
		}
		//exec.shutdown();
		System.out.println(System.getProperty("java.class.path"));
	}

}
